﻿namespace StyleCop.For.ReSharper.QuickFixes.Framework
{
    #region Using Directives

    using System.Drawing;
    using System.IO;
    using System.Reflection;

    using JetBrains.ReSharper.Feature.Services.Bulbs;

    #endregion

    /// <summary>
    /// ReSharper Attribute that allows you to define a custom Icon for a QuickFix
    /// </summary>
    public class ShowQuickFixAttribute : FunctionalGroupAttribute
    {
        /// <summary>
        /// Sets the order the QuickFix should appear. 0 being highest.
        /// </summary>
        public override int Order
        {
            get { return 0; }
        }

        /// <summary>
        /// Returns an image that represents an Icon that will be displayed in the QuickFix
        /// Context Menu.
        /// </summary>
        /// <param name="reason">Availablity Reason for the QF.</param>
        /// <returns>Image representing the icon.</returns>
        public override Image IconForReason(ActionAvailabilityReason reason)
        {
            Image image = null;

            Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("StyleCop.For.ReSharper.Resources.ShowQuickFix.png");

            if (resourceStream != null)
            {
                image = Image.FromStream(resourceStream);
            }

            return image;
        }
    }
}